package com.jetpackframework.skin;

import android.content.Context;
import android.content.res.Configuration;

import com.blankj.utilcode.util.FileUtils;
import com.blankj.utilcode.util.MetaDataUtils;
import com.gwm.annotation.router.AutoService;
import com.jetpackframework.ContextUtil;
import com.jetpackframework.applicationdelegate.ApplicationDelegate;
import com.jetpackframework.applicationdelegate.BaseApplicationDelegate;

@AutoService(ApplicationDelegate.class)
public class SkinApplicationDelegate extends BaseApplicationDelegate {
    private String skResPath;

    @Override
    public void onCreate() {
        String VIRTUAL_FLAG = MetaDataUtils.getMetaDataInApp("VIRTUAL_FLAG");
        if (Boolean.parseBoolean(VIRTUAL_FLAG)) {
            skResPath = ContextUtil.get().getFilesDir() + "/skres";
            FileUtils.createOrExistsDir(skResPath);
            SkinInstaller.install(application, new Skin.Builder()
                    .setSkResPath(skResPath)
                    .build());
        }
    }

    @Override
    public void onLowMemory() {

    }

    @Override
    public void onTrimMemory(int level) {

    }

    @Override
    public void onTerminate() {

    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {

    }

    @Override
    public void onBaseContextAttached(Context base) {

    }

    @Override
    public void exit() {

    }
}
